package test;

import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by 85243 on 2017/3/5.
 */
public class Demo{


    @Test
    public void test01(){
        int a = 1|2;
        System.out.println(a);

        System.out.println(Integer.toBinaryString(16));
        System.out.println(Integer.toHexString(16>>4));
        System.out.println(Integer.toBinaryString(-1));
        System.out.println(Integer.toHexString(-1>>16));
    }


    /**
     * a 和aa里面的list属性为不同对象，所以final是每个对象自己持有的
     */
    @Test
    public void test02(){
        A a  = new A();
        A aa = new A();
        System.out.println(a);
        System.out.println(aa);
    }
    class A{
        private final List list = new ArrayList();

    }


    private static String ss = "";

    public static void main(String[] args) {
        Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    ss = "aaa";
                    Thread.sleep(1000);
                    System.out.println(ss);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });

        Thread t2 = new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    ss = "bbb";
                    Thread.sleep(1000);
                    System.out.println(ss);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });
        t1.start();
        t2.start();
    }


    @Test
    public void test03(){
        int i = -1;
        System.out.println(i%2);
    }


    @Test
    public void test04(){
        Long a = null;
        if(a>0){
            System.out.println(1);
        }
    }


}
